// Pick类型的源码
type Pick<T, K extends keyof T> = { [P in K]: T[P] }

// Pick类型：主要用于抓取 type 、接口、类中的属性组成一个新的对象类型。
type Customer = { name: string, age: number }
interface Book { bookName: string; price: number }
class Vechile { carName!: string; carNo?: number }

type CustomerSub = Pick<Customer, 'name' | 'age'>  // type CustomerSub ={ name: string, age: number }
type BookSub = Pick<Book, 'bookName'>
type VechileSub = Pick<Vechile, 'carName'>

// 复习一下[K in keyof T]，与[P in K]进行区分，巩固记忆
// [K in keyof T]，keyof T是获取T对象类型中的属性名组成的联合类型，in在这里就是循环 这个联合类型。
type CopyObjType<T extends object> = { [K in keyof T]: T[K] }
type CustomerCopy = CopyObjType<Customer>  // type CustomerCopy = { name: string, age: number }
export {}